<template>
  <div class="walletIndexPage">
    <div class="fixedBox">
      <div class="headerBox">
        <p class="headerTitle">钱包</p>
        <!-- <p class="headerTxt"><img src="@/assets/img/wallet/icon_shuaxin@2x.png" alt="" @click="noFunc"> 切换节点</p> -->
        <p class="handlerBtn" @click="go('withdraw')">FIL提现</p>
      </div>
    </div>
    <div class="balanceBoxBox" :style="{'paddingTop': `calc(${1+'rem + '+$headerH+'px'})`}">
      <div class="balanceBox">
        <div class="balanceT">
          <p>钱包余额</p>
          <p class="balanceBtn" @click="go('walletManage')"><img src="@/assets/img/wallet/shezhi-5@2x.png" alt=""> 钱包管理</p>
        </div>
        <div class="balanceB">
          <span class="txt1">FIL</span>
          <span class="txt2">{{$selfFunc.toNonExponential(dataDetail.balance)}}</span>
          <!-- <span class="txt1" style="margin-left:0.12rem">≈</span>
          <span class="txt2">{{$selfFunc.toNonExponential(dataDetail.balanceCNY,2)}}</span>
          <span class="txt1" style="margin-left:0.12rem">CNY</span> -->
        </div>
      </div>
    </div>
    <div class="walletContent">
      <!-- <van-tabs v-model="tabActive" @disabled="onClickDisabled"> -->
      <van-tabs v-model="tabActive">
        <van-tab title="我的矿场">
          <div v-if="dataList.length>0">
            <div class="titleBox">
              <p class="labelTitleL">我的矿场</p>
            </div>

            <div class="subWalletBox">
              <div class="subWallet">
                <div class="hour24Box" v-for="(item,index) in dataList" :key="index">
                  <div class="hourTitle flex">
                    <p>
                      {{item.minerName}}
                      <span class="numberTip" v-if="item.minerBuildStatus">{{item.minerCode}}</span>
                    </p>
                    <span class="stateType stateType1" v-if="item.minerBuildStatus">正常</span>
                    <span class="stateType stateType2" v-else>建设中</span>
                  </div>
                  <div v-if="item.minerBuildStatus">
                    <p class="subHour">
                      <span>我的矿场份额</span>
                      <span>{{item.goodsTotalNum}}份</span>
                    </p>
                    <p class="subHour">
                      <span>有效算力</span>
                      <span>{{item.actualPower}}</span>
                    </p>
                    <p class="subHour">
                      <span>24h算力增量</span>
                      <span>{{item.actualPowerAddDay}}</span>
                    </p>

                    <p class="subHour">
                      <span>累计出块奖励</span>
                      <span>{{$selfFunc.toNonExponential(item.availableFil,4)}}</span>
                    </p>
                    <p class="subHour">
                      <span>
                        24h出块奖励
                        <span class="txt5">*锁定{{$selfFunc.toNonExponential(item.lockedFil,4)}}</span>
                      </span>
                      <span>{{$selfFunc.toNonExponential(item.availableFilAddDay,4)}}</span>
                    </p>
                  </div>
                  <div class="noWallet" v-if="!item.minerBuildStatus">
                    <img src="@/assets/img/user/img_jianshe@2x.png" alt />
                    <p>矿场建设中...</p>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="noWallet noWallet2" v-if="!loading&&dataList.length==0">
            <img src="@/assets/img/wallet/img_qianbao2@2x.png" alt />
            <p>您还没有矿场哦</p>
            <p class="handlerBtn handlerBtn1 goBuy" @click="go('index')">购 买</p>
          </div>
        </van-tab>
        <van-tab title="我的收益">
          <div class="subWallet subWallet2">
            <div class="titleBox">
              <p class="labelTitleL">我的FIL收益</p>
              <p class="labelTitleR" @click="go('returnsDetail')">收益明细</p>
            </div>
            <div class="FILBalance">
              <p class="txt6">累计收益</p>
              <p class="txt6">0FIL</p>
            </div>
            <div class="hour24Box">
              <p class="hourTitle">24小时挖矿收益</p>
              <p class="subHour">
                <span>可用FIL</span>
                <span>0FIL</span>
              </p>
              <p class="subHour">
                <span>锁定FIL</span>
                <span>0FIL</span>
              </p>
              <p class="subHour">
                <span>奖励FIL</span>
                <span>0FIL</span>
              </p>
              <p class="subHour">
                <span>锁定比例</span>
                <span>50%</span>
              </p>
              <p class="subHour">
                <span>锁定期限</span>
                <span>30天</span>
              </p>
            </div>
            <div class="handlerBox">
              <p class="handlerBtn handlerBtn1" @click="go('transferAccount')">转 账</p>
              <p class="handlerBtn handlerBtn2" @click="go('collectionAccount')">收 款</p>
            </div>
          </div>
        </van-tab>
      </van-tabs>
    </div>
    <pay-style ref="payStyle"></pay-style>
  </div>
</template>


<script>
import payStyle from "../../components/payStyle/index";
export default {
  data() {
    return {
      dataDetail: {},
      dataList: [],
      tabActive: "1",
      num: 10,
      loading: true,
      headerH:localStorage.getItem('headerH')
    };
  },
  components: { "pay-style": payStyle },
  activated() {
    this.getWalletInfo();
  },
  methods: {
    go(name) {
      this.$router.push({ name: name });
    },
    goBuy() {
      this.$refs.payStyle.popupShow = true;
    },
    noFunc() {
      this.$toast("该功能正在建设中");
    },
    async getUserFilInfo() {
      let res = await this.$http.getUserFilInfo();
      if (res) {
        this.dataDetail = res.data;
      }
    },
    async getWalletInfo() {
      let res = await this.$http.walletInfoList();
      if (res) {
        this.loading = false;
        this.dataList = res.data;
      } else {
        this.loading = false;
      }
    },
    onClickDisabled(val) {
      this.$toast("该功能正在建设中");
    }
  }
};
</script>
<style>
.walletIndexPage .van-swipe__indicators {
  left: auto !important;
  right: -0.2rem;
  bottom: 0.15rem;
}
.walletIndexPage .van-swipe__indicator.van-swipe__indicator--active {
  width: 0.24rem;
  height: 0.12rem;
  background: rgba(2, 186, 214, 1) !important;
  border-radius: 0.08rem;
}
.walletIndexPage .van-swipe__indicator {
  width: 0.12rem;
  height: 0.12rem;
  background: #c8ceda !important;
  opacity: 1 !important;
}
.walletIndexPage .van-stepper__minus,
.walletIndexPage .van-stepper__plus,
.walletIndexPage .van-stepper__input,
.walletIndexPage .van-stepper__plus {
  background-color: #fff;
}
#app .walletIndexPage .van-tabs__line {
  width: 0.64rem !important;
}
</style>
<style scoped>
.walletIndexPage {
  min-height: 100vh;
  /* background: #fff; */
}
.fixedBox {
  position: fixed;
  width: 100%;
  z-index: 1;
  background: #fff;
}
.headerBox {
  height: 0.8rem;
  line-height: 0.8rem;
  margin-bottom: 0.2rem;
  padding: 0 0.28rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.headerBox .headerTitle {
  font-size: 0.44rem;
  font-weight: 600;
}
.headerBox .headerTxt {
  font-size: 0.29rem;
  display: flex;
  align-items: center;
}
.headerBox .headerTxt img {
  width: 0.48rem;
  height: 0.48rem;
}
.headerBox .handlerBtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 0.6rem;
  color: #F6741F;
  border: 1px solid #F6741F;
  font-size: 0.28rem;
}
.balanceBoxBox{
  background: #fff;
  padding-top: 1rem;
}
.balanceBox {
  height: 1.7rem;
  background: #00c8e7;
  border-radius: 0.08rem 0.08rem 0px 0px;
  margin: 0 0.28rem;
  color: #fff;
  box-sizing: content-box;
}
.balanceT {
  height: 0.76rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-left: 0.2rem;
  padding-right: 0.2rem;
}
.balanceBtn {
  font-size: 0.24rem;
  display: flex;
  align-items: center;
}
.balanceBtn img{
  width: 0.3rem;
  height: 0.3rem;
  margin-right: 0.08rem;
}
.balanceB {
  height: 0.76rem;
  line-height: 0.72rem;
  background: #0493a9;
  padding-left: 0.4rem;
}
.txt1 {
  font-size: 0.24rem;
  margin-right: 0.12rem;
}
.txt2 {
  font-size: 0.32rem;
}
.txt3 {
  font-size: 0.26rem;
  margin-bottom: 0.16rem;
}
.txt4 {
  font-size: 0.32rem;
  font-weight: 600;
}
.txt5 {
  font-size: 0.24rem;
  color: #f30f0f;
}
.txt6 {
  font-size: 0.3rem;
}
.txt7 {
  font-size: 0.3rem;
  font-weight: 600;
}
.txt8 {
  font-size: 0.26rem;
  font-weight: 600;
}
.txt9 {
  font-size: 0.36rem;
  font-weight: 600;
}
.block1 {
  padding: 0.2rem;
  background: #f3f3f3;
  border-radius: 0.08rem;
  margin-bottom: 0.14rem;
}
.walletContent {
  margin-top: -0.26rem;
  margin-bottom: 1.2rem;
  box-shadow: 0 -9px 10px -3px rgba(17,24,28,0.21);
}
.subWallet {
  padding: 0 0.28rem;
  padding-top: 0.2rem;
}
.titleBox {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.2rem 0.28rem;
  padding-top: 0.4rem;
  background: #fff;
}
.labelTitleL {
  font-size: 0.34rem;
  font-weight: 600;
}
.labelTitleL::before {
  display: inline-block;
  top: -0.02rem;
  content: "";
  position: relative;
  width: 0.06rem;
  height: 0.16rem;
  background: #00c8e7;
  border-radius: 0.03rem;
  margin-right: 0.14rem;
}
.labelTitleR {
  color: #9b9b9b;
}
.labelTitleR::after {
  display: inline-block;
  content: "";
  position: relative;
  width: 0.24rem;
  height: 0.24rem;
  background: url("../../assets/img/login/icon_xiangxia.png");
  background-size: contain;
  transform: rotate(270deg);
  vertical-align: middle;
}
.dataInfo {
  padding-bottom: 0.3rem;
}
.FILBalance {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.2rem 0.27rem;
  background: #fff;
}
.hour24Box {
  background: #fff;
  border-radius: 0.08rem;
  margin-bottom: 0.2rem;
}
.hourTitle {
  height: 0.82rem;
  line-height: 0.82rem;
  font-size: 0.29rem;
  font-weight: 600;
  margin: 0 0.2rem;
  border-bottom: 1px dashed #ececec;
}
.hourTitle2 {
  background: rgba(160, 160, 160, 0.12);
}
.subHour {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 0.76rem;
  margin: 0 0.2rem;
}
.subHour:last-child {
  border-bottom: none;
}
.handlerBox {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 1rem;
  background: #fff;
  padding: 0.2rem 0.4rem;
}
.handlerBtn {
  height: 0.82rem;
  line-height: 0.82rem;
  border-radius: 0.41rem;
  text-align: center;
  color: #fff;
  font-size: 0.34rem;
}
.handlerBtn1 {
  width: 2.58rem;
  background: #00c8e7;
}
.handlerBtn2 {
  width: 3.96rem;
  background: #f6741f;
}
.handlerBtn3 {
  width: 100%;
  background: #f6741f;
}
.noShopBox {
  text-align: center;
}
.noShopBox p {
  color: #999999;
  text-align: center;
  font-size: 0.32rem;
}
.noShopBox img {
  width: 100%;
}
.shopBox {
  padding: 0 0.28rem;
}
.shopInfo {
  display: flex;
  align-items: center;
  background: #f3f3f3;
  border-radius: 0.08rem;
  padding: 0.18rem 0.34rem;
  margin-bottom: 0.2rem;
}
.shopInfo > div {
  position: relative;
  flex: 1;
  text-align: center;
}
.shopInfo > div::after {
  display: inline-block;
  position: absolute;
  right: 0;
  top: 0.18rem;
  content: "";
  width: 1px;
  height: 0.58rem;
  background: #d6d6d6;
}
.shopInfo > div:last-child::after {
  width: 0;
}
.shopInfo > div p:first-child {
  margin-bottom: 0.15rem;
}
.waitBox {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 0.96rem;
  background: #f3f3f3;
  border-radius: 0.08rem;
  padding: 0 0.3rem;
  padding-right: 0.2rem;
  margin-bottom: 0.3rem;
}
.waitBox .iconT {
  width: 0.4rem;
  height: 0.4rem;
  vertical-align: middle;
  margin-right: 0.1rem;
}
.goodsBox {
  background: #f3f3f3;
  border-radius: 0.08rem;
  padding: 0.2rem;
  margin-bottom: 0.4rem;
}
.subGoods {
  position: relative;
  display: flex;
}
.subGoodsR {
  width: 100%;
}
.subGoodsL img {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 0.08rem;
  margin-right: 0.16rem;
}
.money2 {
  color: #f30f0f;
  font-weight: 600;
}
.shopLabel {
  display: flex;
  align-items: center;
  height: 0.52rem;
  line-height: 0.52rem;
  margin-top: 0.08rem;
  margin-bottom: 0.2rem;
}
.shopLabel p {
  display: flex;
  align-items: center;
}
.shopLabel img {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  margin-left: 0.12rem;
}
.shopLabel span {
  margin: 0 0.12rem;
  font-size: 0.29rem;
}
.stepper {
  position: absolute;
  right: 0;
  bottom: 0;
}
.stateType {
  font-weight: normal;
}
.stateType::before {
  display: inline-block;
  content: "";
  width: 0.1rem;
  height: 0.1rem;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 0.12rem;
}
.stateType1::before {
  background: #52c41a;
}
.stateType2::before {
  background: #f30f0f;
}
.numberTip {
  padding: 0.05rem 0.16rem;
  background: rgba(0, 200, 231, 0.09);
  font-size: 0.26rem;
  margin-left: 0.1rem;
}
.noWallet {
  text-align: center;
  font-size: 0.32rem;
  color: #999;
  padding-bottom: 0.4rem;
}
.noWallet img {
  width: 60%;
}
.noWallet2{
  padding-bottom: 1rem;
}
.noWallet2 img {
  width: 100%;
}
.goBuy {
  margin: 0 auto;
  margin-top: 0.6rem;
}
.subWallet2{
  background: #fff;
  padding-bottom: 0.1rem;
}
</style>
